/*
 * Pad_Control_SW.c
 *
 * Created: 30/11/2012 11:10:10 p.m.
 *  Author: Rober
 */ 
#define F_CPU 8000000UL

#include <avr/io.h>
#include "avr/delay.h"
#include "MyDefines.h"
#include "usart.h"

//#include "pad.h"

//RAM VARIABLES

enum
{
	Msg_ERROR,
	Msg_READY,
	Msg_START,
	Msg_STOP,
	Msg_RXTEST,
	Msg_TXTEST
}E_RxMessages;

enum
{
	SYS_ERROR,
	SYS_READY,
	SYS_START,
	SYS_STOP,
	SYS_RXTEST,
	SYS_TXTEST
}E_SystemState;

unsigned char name[3]={0x52,0x4f,0x42};
int main(void)
{
	unsigned char n;
	//pad_init();
	usart_init();
	//sei();
	DDRA=0xFF;
	PORTA=0XAA;
	DDRD|=(1<<7);
    while(1)
    {
		for (n=0;n<3;n++)
		{
			_delay_ms(100);
			usart_send(name[n]);
		}
		/*switch (E_RxMessages)
		{
			
				
		}*/
		 
    }
}


ISR(USART_RXC_vect)
{
	rub_MsgReceived = usart_read();
	usart_send(usart_read());
	
	switch (rub_MsgReceived)
	{	
		case 0x01:
			E_RxMessages = Msg_READY;
			break;
			
		case 0x02:
			E_RxMessages = Msg_START;
			break;
		
		case 0x03:
			E_RxMessages = Msg_STOP;
			break;
		
		case 0xDD:
			E_RxMessages = Msg_TXTEST;
			break;
			
		case 0xAA:
			E_RxMessages = Msg_RXTEST;
			break;
		
		default:
			E_RxMessages = Msg_ERROR;
			break;
	}
}